cap log close 
log using "${logpath}district_regressions.log", replace

/*******************************************************************************
district_regressions.do

Analyzes district-level data
*******************************************************************************/

clear all

use "${cleandatapath}dist_data.dta", clear

qui {
	foreach type in crim civ PA {
		gen months_since_`type'=month_date-mofd(`type'_date)
		replace months_since_`type'=. if months_since_`type'<-24 | months_since_`type'>23
		bysort dist_code: egen max_since_`type'=max(months_since_`type')
		bysort dist_code: egen min_since_`type'=min(months_since_`type')
		replace months_since_`type'=. if max_since_`type'!=23 | min_since_`type'!=-24
		replace months_since_`type'=-50 if missing(`type'_date)
		gen months_since_`type'100=months_since_`type'+100
		gen months_since_`type'100_firm=months_since_`type'100
		replace months_since_`type'100_firm=. if mofd(`type'_date)<ym(2014,1)
		gen post_together_`type'=months_since_`type'100
		replace post_together_`type'=100 if months_since_`type'100>100 & !missing(months_since_`type'100)
		gen post_together_`type'_firm=post_together_`type'
		replace post_together_`type'_firm=. if mofd(`type'_date)<ym(2014,1)
	}
	drop if dist_code==14 // Dropping Connecticut
	
	gen PA_wave=0 if missing(PA_date)
	replace PA_wave=1 if PA_date==20058
	replace PA_wave=2 if PA_date==20454
}

qui reghdfe log_tot_pmt ib99.months_since_PA100 i.post_crim i.post_civ if month_date>=612, a(dist_code month_date) vce(cluster dist_code)
coefplot, keep(*months_since*) vert baselevel ///
	recast(connected) ciopts(recast(rcap) color(navy)) ///
	xti(Months Since Prior Authorization Implementation) ///
	xlab(1 "-24" 7 "-18" 13 "-12" 19 "-6" 25 "0" ///
		31 "6" 37 "12" 43 "18" 49 "24") ///
	xline(25, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) ///
	yti("Total Payments in District (Logs)") ///
	ylab(, angle(0)) ///
	graphregion(color(white)) bgcolor(white)
qui graph export ${outpath}Figure_3.pdf, as(pdf)  replace // Figure 3

qui reghdfe log_tot_pmt ib99.months_since_civ100 i.prior_auth i.post_crim, a(dist_code month_date) vce(cluster dist_code)
coefplot, keep(*months_since*) vert baselevel ///
	recast(connected) ciopts(recast(rcap) color(navy)) ///
	xti(Months Since First Civil Enforcement) ///
	xlab(1 "-24" 7 "-18" 13 "-12" 19 "-6" 25 "0" ///
		31 "6" 37 "12" 43 "18" 49 "24") ///
	xline(25, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) ///
	yti("Total Payments in District (Logs)") ///
	ylab(, angle(0)) ///
	graphregion(color(white)) bgcolor(white)
qui graph export ${outpath}Figure_4a.pdf, as(pdf)  replace // Figure 4a

qui reghdfe log_tot_pmt ib99.months_since_crim100 i.prior_auth i.post_civ, a(dist_code month_date) vce(cluster dist_code)
coefplot, keep(*months_since*) vert baselevel ///
	recast(connected) ciopts(recast(rcap) color(navy)) ///
	xti(Months Since First Criminal Enforcement) ///
	xlab(1 "-24" 7 "-18" 13 "-12" 19 "-6" 25 "0" ///
		31 "6" 37 "12" 43 "18" 49 "24") ///
	xline(25, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) ///
	yti("Total Payments in District (Logs)") ///
	ylab(, angle(0)) ///
	graphregion(color(white)) bgcolor(white)
qui graph export ${outpath}Figure_4b.pdf, as(pdf)  replace // Figure 4b

qui reghdfe log_active_firms ib99.months_since_PA100_firm i.post_crim i.post_civ if month_date>=624, a(dist_code month_date) vce(cluster dist_code)
coefplot, keep(*months_since*) vert baselevel ///
	recast(connected) ciopts(recast(rcap) color(navy)) ///
	xti(Months Since Prior Authorization Implementation) ///
	xlab(1 "-24" 7 "-18" 13 "-12" 19 "-6" 25 "0" ///
		31 "6" 37 "12" 43 "18" 49 "24") ///
	xline(25, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) ///
	yti("Active Firms in District (Logs)") ///
	ylab(, angle(0)) ///
	graphregion(color(white)) bgcolor(white)
qui graph export ${outpath}Figure_6.pdf, as(pdf)  replace // Figure 6

qui reghdfe log_tot_pmt ib99.months_since_civ100 i.prior_auth i.post_crim if  months_since_civ100!=50, a(dist_code) vce(cluster dist_code)
coefplot, keep(*months_since*) vert baselevel ///
	recast(connected) ciopts(recast(rcap) color(navy)) ///
	xti(Months Since First Civil Enforcement) ///
	xlab(1 "-24" 7 "-18" 13 "-12" 19 "-6" 25 "0" ///
		31 "6" 37 "12" 43 "18" 49 "24") ///
	xline(25, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) ///
	yti("Total Payments in District (Logs)") ///
	ylab(, angle(0)) ///
	graphregion(color(white)) bgcolor(white)
qui graph export ${outpath}Figure_A8a.pdf, as(pdf)  replace // Figure A8a

qui reghdfe log_tot_pmt ib99.months_since_crim100 i.prior_auth i.post_civ if months_since_crim100!=50, a(dist_code) vce(cluster dist_code)
coefplot, keep(*months_since*) vert baselevel ///
	recast(connected) ciopts(recast(rcap) color(navy)) ///
	xti(Months Since First Criminal Enforcement) ///
	xlab(1 "-24" 7 "-18" 13 "-12" 19 "-6" 25 "0" ///
		31 "6" 37 "12" 43 "18" 49 "24") ///
	xline(25, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) ///
	yti("Total Payments in District (Logs)") ///
	ylab(, angle(0)) ///
	graphregion(color(white)) bgcolor(white)
qui graph export ${outpath}Figure_A15b.pdf, as(pdf)  replace // Figure A8b

qui reghdfe log_tot_pmt ib99.months_since_civ100 i.prior_auth i.post_crim if first_civil_spill!=0 | !missing(civ_date), a(dist_code month_date) vce(cluster dist_code)
coefplot, keep(*months_since*) vert baselevel ///
	recast(connected) ciopts(recast(rcap) color(navy)) ///
	xti(Months Since First Civil Enforcement) ///
	xlab(1 "-24" 7 "-18" 13 "-12" 19 "-6" 25 "0" ///
		31 "6" 37 "12" 43 "18" 49 "24") ///
	xline(25, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) ///
	yti("Total Payments in District (Logs)") ///
	ylab(, angle(0)) ///
	graphregion(color(white)) bgcolor(white)
qui graph export ${outpath}Figure_A9a.pdf, as(pdf)  replace // Figure A9a

qui reghdfe log_tot_pmt ib99.months_since_crim100 i.prior_auth i.post_civ if first_criminal_spill!=0 | !missing(crim_date), a(dist_code month_date) vce(cluster dist_code)
coefplot, keep(*months_since*) vert baselevel ///
	recast(connected) ciopts(recast(rcap) color(navy)) ///
	xti(Months Since First Criminal Enforcement) ///
	xlab(1 "-24" 7 "-18" 13 "-12" 19 "-6" 25 "0" ///
		31 "6" 37 "12" 43 "18" 49 "24") ///
	xline(25, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) ///
	yti("Total Payments in District (Logs)") ///
	ylab(, angle(0)) ///
	graphregion(color(white)) bgcolor(white)
qui graph export ${outpath}Figure_A9b.pdf, as(pdf)  replace // Figure A9b

qui reghdfe log_tot_pmt ib99.months_since_PA100 i.post_crim i.post_civ if month_date>=612 & PA_wave!=2, a(dist_code month_date) vce(cluster dist_code)
coefplot, keep(*months_since*) vert baselevel ///
	recast(connected) ciopts(recast(rcap) color(navy)) ///
	xti(Months Since Prior Authorization Implementation) ///
	xlab(1 "-24" 7 "-18" 13 "-12" 19 "-6" 25 "0" ///
		31 "6" 37 "12" 43 "18" 49 "24") ///
	xline(25, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) ///
	yti("Total Payments in District (Logs)") ///
	ylab(, angle(0)) ///
	graphregion(color(white)) bgcolor(white)
qui graph export ${outpath}Figure_A10a.pdf, as(pdf)  replace // Figure A10a

qui reghdfe log_tot_pmt ib99.months_since_PA100 i.post_crim i.post_civ if month_date>=612 & PA_wave!=1, a(dist_code month_date) vce(cluster dist_code)
coefplot, keep(*months_since*) vert baselevel ///
	recast(connected) ciopts(recast(rcap) color(navy)) ///
	xti(Months Since Prior Authorization Implementation) ///
	xlab(1 "-24" 7 "-18" 13 "-12" 19 "-6" 25 "0" ///
		31 "6" 37 "12" 43 "18" 49 "24") ///
	xline(25, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) ///
	yti("Total Payments in District (Logs)") ///
	ylab(, angle(0)) ///
	graphregion(color(white)) bgcolor(white)
qui graph export ${outpath}Figure_A10b.pdf, as(pdf)  replace // Figure A10b

label var tot_pmt "\shortstack{Total Ride \\ Payments}"
label var log_tot_pmt "\shortstack{Total Ride \\ Payments (Log)}"
label var ambulance_id "\shortstack{Total \\ Rides}"
label var log_rides "\shortstack{Total \\ Rides (Log)}"
label var active_firms "\shortstack{Active \\ Firms}"
label var log_active_firms "\shortstack{Active \\ Firms (Log)}"
label var ihs_pmt "\shortstack{Total Ride \\ Payments (IHS)}"
label var ihs_rides "\shortstack{Total \\ Rides (IHS)}"
label var ihs_firms "\shortstack{Active \\ Firms (IHS)}"
label var emerg_pmt "\shortstack{Payments for \\ Emergency Rides}"
label var log_emerg_pmt "\shortstack{Payments for \\ Emergency Rides (Log)}"
label var emerg_rides "\shortstack{Total Emergency \\ Rides}"
label var log_emerg_rides "\shortstack{Total Emergency \\ Rides (Log)}"

qui bysort dist_code: egen base_ridess=mean(ambulance_id) if year<=2005
bysort dist_code: egen base_rides=max(base_ridess)
gen anylit=(months_since_civ!=-50 | months_since_crim!=-50)

qui {
	*Estimates for Tables 2-3, 6, A10-3, A15-21, A32
	gen post_together=.
	gen post_inter=.
	gen post_inter_dum=.
	foreach var in tot_pmt log_tot_pmt ihs_pmt ambulance_id log_rides ihs_rides active_firms log_active_firms ihs_firms emerg_pmt log_emerg_pmt emerg_rides log_emerg_rides {
		local suff=""
		if "`var'"=="active_firms" | "`var'"=="log_active_firms" | "`var'"=="ihs_firms" {
			local suff="_firm"
		}
		
		if ~inlist("`var'","active_firms","log_active_firms","ihs_firms", "emerg_pmt", "log_emerg_pmt", "emerg_rides", "log_emerg_rides") {
			replace post_together=post_together_civ`suff'
			reghdfe `var' ib99.post_together i.post_crim i.prior_auth, a(dist_code month_date) vce(cluster dist_code)
			estadd ysumm
			estimates save ${estpath}TWFE_civil_`var', replace
			
			if inlist("`var'","log_tot_pmt","log_rides") {
				reghdfe `var' ib99.post_together i.post_crim i.prior_auth if first_civil_spill!=0 | !missing(civ_date), a(dist_code month_date) vce(cluster dist_code)
				estadd ysumm
				estimates save ${estpath}TWFE_civil_`var'_closecontrol, replace
				
				replace post_inter_dum=PA_wave!=0
				reghdfe `var' ib99.post_together##c.post_inter_dum i.post_crim i.prior_auth, a(dist_code month_date) vce(cluster dist_code)
				estadd ysumm
				estimates save ${estpath}TWFE_civil_`var'_PAinter, replace
				
				replace post_inter=(mofd(civ_date)-ym(2003,1))
				replace post_inter=0 if missing(post_inter)
				su post_inter if post_together==100
				replace post_inter=post_inter-`r(mean)'
				reghdfe `var' ib99.post_together##c.post_inter i.post_crim i.prior_auth, a(dist_code month_date) vce(cluster dist_code)
				estadd ysumm
				estimates save ${estpath}TWFE_civil_`var'_timeinter, replace
				
				replace post_inter=log(base_rides)
				su post_inter if post_together==100
				replace post_inter=post_inter-`r(mean)'
				reghdfe `var' ib99.post_together##c.post_inter i.post_crim i.prior_auth, a(dist_code month_date) vce(cluster dist_code)
				estadd ysumm
				estimates save ${estpath}TWFE_civil_`var'_baserides, replace
			}
			if inlist("`var'","tot_pmt","ambulance_id") {
				ppmlhdfe `var' ib99.post_together i.post_crim i.prior_auth, a(dist_code month_date) vce(cluster dist_code)
				estadd ysumm
				estimates save ${estpath}pois_civil_`var', replace
			}			

			replace post_together=post_together_crim`suff'
			reghdfe `var' ib99.post_together i.prior_auth i.post_civ, a(dist_code month_date) vce(cluster dist_code)
			estadd ysumm
			estimates save ${estpath}TWFE_criminal_`var', replace
			
			if inlist("`var'","log_tot_pmt","log_rides") {
				reghdfe `var' ib99.post_together i.prior_auth i.post_civ if first_criminal_spill!=0 | !missing(crim_date), a(dist_code month_date) vce(cluster dist_code)
				estadd ysumm
				estimates save ${estpath}TWFE_criminal_`var'_closecontrol, replace
				
				replace post_inter_dum=PA_wave!=0
				reghdfe `var' ib99.post_together##c.post_inter_dum i.post_civ i.prior_auth, a(dist_code month_date) vce(cluster dist_code)
				estadd ysumm
				estimates save ${estpath}TWFE_criminal_`var'_PAinter, replace
				
				replace post_inter=(mofd(crim_date)-ym(2003,1))
				replace post_inter=0 if missing(post_inter)
				su post_inter if post_together==100
				replace post_inter=post_inter-`r(mean)'
				reghdfe `var' ib99.post_together##c.post_inter i.prior_auth i.post_civ, a(dist_code month_date) vce(cluster dist_code)
				estadd ysumm
				estimates save ${estpath}TWFE_criminal_`var'_timeinter, replace
				
				replace post_inter=log(base_rides)
				su post_inter if post_together==100
				replace post_inter=post_inter-`r(mean)'
				reghdfe `var' ib99.post_together##c.post_inter i.prior_auth i.post_civ, a(dist_code month_date) vce(cluster dist_code)
				estadd ysumm
				estimates save ${estpath}TWFE_criminal_`var'_baserides, replace
			}
			if inlist("`var'","tot_pmt","ambulance_id") {
				ppmlhdfe `var' ib99.post_together i.post_civ i.prior_auth, a(dist_code month_date) vce(cluster dist_code)
				estadd ysumm
				estimates save ${estpath}pois_criminal_`var', replace
			}			
		}

		replace post_together=post_together_PA`suff'
		reghdfe `var' ib99.post_together i.post_crim i.post_civ if month_date>=612, a(dist_code month_date) vce(cluster dist_code)
		estadd ysumm
		estimates save ${estpath}TWFE_prior_auth_`var', replace
		
		if inlist("`var'","tot_pmt", "log_tot_pmt", "ambulance_id", "log_rides") {
			reghdfe `var' prior_auth post_civ post_crim, a(dist_code month_date) vce(cluster dist_code)
			estadd ysumm
			estimates save ${estpath}TWFE_all_`var', replace
		}
		if inlist("`var'","tot_pmt", "log_tot_pmt", "ambulance_id", "log_rides","active_firms","log_active_firms") {
			replace post_inter=post_together*(PA_wave==2)
			reghdfe `var' ib99.post_together ib99.post_inter i.post_crim i.post_civ if month_date>=612, a(dist_code month_date) vce(cluster dist_code)
			estadd ysumm
			estimates save ${estpath}TWFE_prior_auth_waveinter_`var', replace

			replace post_inter=post_together*anylit
			reghdfe `var' ib99.post_together ib99.post_inter i.post_crim i.post_civ if month_date>=612, a(dist_code month_date) vce(cluster dist_code)
			estadd ysumm
			estimates save ${estpath}TWFE_prior_auth_litinter_`var', replace
		}
		if inlist("`var'","tot_pmt","ambulance_id","active_firms") {
			ppmlhdfe `var' ib99.post_together i.post_crim i.post_civ if month_date>=612, a(dist_code month_date) vce(cluster dist_code)
			estadd ysumm
			estimates save ${estpath}pois_prior_auth_`var', replace
		}			
	}
	
	*Table 2
	estimates clear
	estimates use ${estpath}TWFE_prior_auth_log_tot_pmt
	eststo est1
	eststo est1,addscalars(Year_FE 1)
	eststo est1,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_prior_auth_tot_pmt
	eststo est2
	eststo est2,addscalars(Year_FE 1)
	eststo est2,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_prior_auth_log_rides
	eststo est3
	eststo est3,addscalars(Year_FE 1)
	eststo est3,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_prior_auth_ambulance_id
	eststo est4
	eststo est4,addscalars(Year_FE 1)
	eststo est4,addscalars(Dist_FE 1)

	label var tot_pmt "\shortstack{Total Ride \\ Payments}"
	label var log_tot_pmt "\shortstack{Total Ride \\ Payments (Log)}"
	label var ambulance_id "\shortstack{Total \\ Rides}"
	label var log_rides "\shortstack{Total \\ Rides (Log)}"
	label var active_firms "\shortstack{Active \\ Firms}"
	label var log_active_firms "\shortstack{Active \\ Firms (Log)}"
	label define post 100 "Prior Authorization", replace
	label values post_together post

	esttab using ${outpath}Table_2.tex, ///
		replace label se frag booktabs keep(*100*) ///
		star(+ 0.1 * 0.05 ** 0.01 *** 0.001) ///
		stats(Year_FE Dist_FE ymean N, ///
			label("Year-Month FE" "District FE" "Dep. Var. Mean" "Observations"))
}

di exp(-1.129)-1 // Referenced in Section 1, Paragraph 5 and Section 5.1, Paragraph 2 and Section 7, Paragraph 1
di "Incapacitation Share = " (14*60000)/(9*615088.4) // Referenced in Section 5.4, Paragraph 3

qui {
	*Table 3
	estimates clear
	estimates use ${estpath}TWFE_civil_log_tot_pmt
	eststo est1
	eststo est1,addscalars(Year_FE 1)
	eststo est1,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_civil_log_rides
	eststo est2
	eststo est2,addscalars(Year_FE 1)
	eststo est2,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_criminal_log_tot_pmt
	eststo est3
	eststo est3,addscalars(Year_FE 1)
	eststo est3,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_criminal_log_rides
	eststo est4
	eststo est4,addscalars(Year_FE 1)
	eststo est4,addscalars(Dist_FE 1)
	
	label define post 100 "Enforcement", replace
	label values post_together post

	esttab using ${outpath}Table_3.tex, ///
		replace label se frag booktabs keep(*100*) ///
		star(+ 0.1 * 0.05 ** 0.01 *** 0.001) ///
		mgroups("Civil" "Criminal", pattern(1 0 1 0) ///
			prefix(\multicolumn{@span}{c}{) suffix(}) span ///
			erepeat(\cmidrule(lr){@span})) ///
		stats(Year_FE Dist_FE ymean N, ///
			label("Year-Month FE" "District FE" "Dep. Var. Mean" "Observations"))
}

di exp(-0.211)-1 // Referenced in Section 5.1, Paragraph 5
di exp(-0.280)-1 // Referenced in Section 5.1, Paragraph 5

qui{
	*Table 6
	estimates clear
	estimates use ${estpath}TWFE_prior_auth_log_active_firms
	eststo est1
	eststo est1,addscalars(Year_FE 1)
	eststo est1,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_prior_auth_active_firms
	eststo est2
	eststo est2,addscalars(Year_FE 1)
	eststo est2,addscalars(Dist_FE 1)
	
	label define post 100 "Prior Authorization", replace
	label values post_together post

	esttab est1 est2 using ${outpath}Table_6.tex, ///
		replace label se frag booktabs keep(*100*) ///
		star(+ 0.1 * 0.05 ** 0.01 *** 0.001) ///
		stats(Year_FE Dist_FE ymean N, ///
			label("Year-Month FE" "District FE" "Dep. Var. Mean" "Observations"))
}

di exp(-0.286)-1 // Referenced in Section 5.3, Paragraph 1 and Appendix J.2, Bullet 2

qui {
	*Table A22
	estimates clear
	estimates use ${estpath}TWFE_prior_auth_log_emerg_pmt
	eststo est1
	eststo est1,addscalars(Year_FE 1)
	eststo est1,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_prior_auth_emerg_pmt
	eststo est2
	eststo est2,addscalars(Year_FE 1)
	eststo est2,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_prior_auth_log_emerg_rides
	eststo est3
	eststo est3,addscalars(Year_FE 1)
	eststo est3,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_prior_auth_emerg_rides
	eststo est4
	eststo est4,addscalars(Year_FE 1)
	eststo est4,addscalars(Dist_FE 1)

	label var emerg_pmt "\shortstack{Payments for \\ Emergency Rides}"
	label var log_emerg_pmt "\shortstack{Payments for \\ Emergency Rides (Log)}"
	label var emerg_rides "\shortstack{Total Emergency \\ Rides}"
	label var log_emerg_rides "\shortstack{Total Emergency \\ Rides (Log)}"

	esttab using ${outpath}Table_A22.tex, ///
		replace label se frag booktabs keep(*100*) ///
		star(+ 0.1 * 0.05 ** 0.01 *** 0.001) ///
		stats(Year_FE Dist_FE ymean N, ///
			label("Year-Month FE" "District FE" "Dep. Var. Mean" "Observations"))
		
	*Table A13
	estimates clear
	estimates use ${estpath}TWFE_civil_tot_pmt
	eststo est1
	eststo est1,addscalars(Year_FE 1)
	eststo est1,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_civil_ambulance_id
	eststo est2
	eststo est2,addscalars(Year_FE 1)
	eststo est2,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_criminal_tot_pmt
	eststo est3
	eststo est3,addscalars(Year_FE 1)
	eststo est3,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_criminal_ambulance_id
	eststo est4
	eststo est4,addscalars(Year_FE 1)
	eststo est4,addscalars(Dist_FE 1)
	
	label define post 100 "Enforcement", replace
	label values post_together post

	esttab using ${outpath}Table_A13.tex, ///
		replace label se frag booktabs keep(*100*) ///
		star(+ 0.1 * 0.05 ** 0.01 *** 0.001) ///
		mgroups("Civil" "Criminal", pattern(1 0 1 0) ///
			prefix(\multicolumn{@span}{c}{) suffix(}) span ///
			erepeat(\cmidrule(lr){@span})) ///
		stats(Year_FE Dist_FE ymean N, ///
			label("Year-Month FE" "District FE" "Dep. Var. Mean" "Observations"))
		
	*Table A15
	estimates clear
	estimates use ${estpath}TWFE_civil_log_tot_pmt_closecontrol
	eststo est1
	eststo est1,addscalars(Year_FE 1)
	eststo est1,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_civil_log_rides_closecontrol
	eststo est2
	eststo est2,addscalars(Year_FE 1)
	eststo est2,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_criminal_log_tot_pmt_closecontrol
	eststo est3
	eststo est3,addscalars(Year_FE 1)
	eststo est3,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_criminal_log_rides_closecontrol
	eststo est4
	eststo est4,addscalars(Year_FE 1)
	eststo est4,addscalars(Dist_FE 1)

	esttab using ${outpath}Table_A15.tex, ///
		replace label se frag booktabs keep(*100*) ///
		star(+ 0.1 * 0.05 ** 0.01 *** 0.001) ///
		mgroups("Civil" "Criminal", pattern(1 0 1 0) ///
			prefix(\multicolumn{@span}{c}{) suffix(}) span ///
			erepeat(\cmidrule(lr){@span})) ///
		stats(Year_FE Dist_FE ymean N, ///
			label("Year-Month FE" "District FE" "Dep. Var. Mean" "Observations"))
	
	*Table A16
	estimates clear
	estimates use ${estpath}TWFE_prior_auth_waveinter_log_tot_pmt
	eststo est1
	eststo est1,addscalars(Year_FE 1)
	eststo est1,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_prior_auth_waveinter_tot_pmt
	eststo est2
	eststo est2,addscalars(Year_FE 1)
	eststo est2,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_prior_auth_waveinter_log_rides
	eststo est3
	eststo est3,addscalars(Year_FE 1)
	eststo est3,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_prior_auth_waveinter_ambulance_id
	eststo est4
	eststo est4,addscalars(Year_FE 1)
	eststo est4,addscalars(Dist_FE 1)
	
	label define post 100 "Prior Authorization", replace
	label values post_together post
	label define inter 100 "Prior Auth. $\times$ Second Wave", replace
	label values post_inter inter
	
	esttab using ${outpath}Table_A16.tex, ///
		replace label se frag booktabs keep(*100*) ///
		star(+ 0.1 * 0.05 ** 0.01 *** 0.001) ///
		stats(Year_FE Dist_FE ymean N, ///
			label("Year-Month FE" "District FE" "Dep. Var. Mean" "Observations"))

	*Table A17
	estimates clear
	estimates use ${estpath}TWFE_prior_auth_litinter_log_tot_pmt
	eststo est1
	eststo est1,addscalars(Year_FE 1)
	eststo est1,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_prior_auth_litinter_tot_pmt
	eststo est2
	eststo est2,addscalars(Year_FE 1)
	eststo est2,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_prior_auth_litinter_log_rides
	eststo est3
	eststo est3,addscalars(Year_FE 1)
	eststo est3,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_prior_auth_litinter_ambulance_id
	eststo est4
	eststo est4,addscalars(Year_FE 1)
	eststo est4,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_prior_auth_litinter_log_active_firms
	eststo est5
	eststo est5,addscalars(Year_FE 1)
	eststo est5,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_prior_auth_litinter_active_firms
	eststo est6
	eststo est6,addscalars(Year_FE 1)
	eststo est6,addscalars(Dist_FE 1)
	
	label define inter 100 "Prior Auth. $\times$ Litigation", replace
	label values post_inter inter

	esttab using ${outpath}Table_A17.tex, ///
		replace label se frag booktabs keep(*100*) ///
		star(+ 0.1 * 0.05 ** 0.01 *** 0.001) ///
		stats(Year_FE Dist_FE ymean N, ///
			label("Year-Month FE" "District FE" "Dep. Var. Mean" "Observations"))
	
	*Table A18
	estimates clear
	estimates use ${estpath}TWFE_civil_log_tot_pmt_timeinter
	eststo est1
	eststo est1,addscalars(Year_FE 1)
	eststo est1,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_civil_log_rides_timeinter
	eststo est2
	eststo est2,addscalars(Year_FE 1)
	eststo est2,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_criminal_log_tot_pmt_timeinter
	eststo est3
	eststo est3,addscalars(Year_FE 1)
	eststo est3,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_criminal_log_rides_timeinter
	eststo est4
	eststo est4,addscalars(Year_FE 1)
	eststo est4,addscalars(Dist_FE 1)
	
	label define post 100 "Enforcement", replace
	label values post_together post
	label var post_inter "Enforcement Date"

	esttab using ${outpath}Table_A18.tex, ///
		replace label se frag booktabs keep(*100*) ///
		star(+ 0.1 * 0.05 ** 0.01 *** 0.001) ///
		mgroups("Civil" "Criminal", pattern(1 0 1 0) ///
			prefix(\multicolumn{@span}{c}{) suffix(}) span ///
			erepeat(\cmidrule(lr){@span})) ///
		stats(Year_FE Dist_FE ymean N, ///
			label("Year-Month FE" "District FE" "Dep. Var. Mean" "Observations"))
	
	*Table A19
	estimates clear
	estimates use ${estpath}TWFE_civil_log_tot_pmt_baserides
	eststo est1
	eststo est1,addscalars(Year_FE 1)
	eststo est1,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_civil_log_rides_baserides
	eststo est2
	eststo est2,addscalars(Year_FE 1)
	eststo est2,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_criminal_log_tot_pmt_baserides
	eststo est3
	eststo est3,addscalars(Year_FE 1)
	eststo est3,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_criminal_log_rides_baserides
	eststo est4
	eststo est4,addscalars(Year_FE 1)
	eststo est4,addscalars(Dist_FE 1)

	label values post_together post
	label var post_inter "Baseline Ridership"

	esttab using ${outpath}Table_A19.tex, ///
		replace label se frag booktabs keep(*100*) ///
		star(+ 0.1 * 0.05 ** 0.01 *** 0.001) ///
		mgroups("Civil" "Criminal", pattern(1 0 1 0) ///
			prefix(\multicolumn{@span}{c}{) suffix(}) span ///
			erepeat(\cmidrule(lr){@span})) ///
		stats(Year_FE Dist_FE ymean N, ///
			label("Year-Month FE" "District FE" "Dep. Var. Mean" "Observations"))

	*Table A21
	estimates clear
	estimates use ${estpath}TWFE_civil_log_tot_pmt_PAinter
	eststo est1
	eststo est1,addscalars(Year_FE 1)
	eststo est1,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_civil_log_rides_PAinter
	eststo est2
	eststo est2,addscalars(Year_FE 1)
	eststo est2,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_criminal_log_tot_pmt_PAinter
	eststo est3
	eststo est3,addscalars(Year_FE 1)
	eststo est3,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_criminal_log_rides_PAinter
	eststo est4
	eststo est4,addscalars(Year_FE 1)
	eststo est4,addscalars(Dist_FE 1)

	label var post_inter_dum "Prior Auth."

	esttab using ${outpath}Table_A21.tex, ///
		replace label se frag booktabs keep(*100*) ///
		star(+ 0.1 * 0.05 ** 0.01 *** 0.001) ///
		mgroups("Civil" "Criminal", pattern(1 0 1 0) ///
			prefix(\multicolumn{@span}{c}{) suffix(}) span ///
			erepeat(\cmidrule(lr){@span})) ///
		stats(Year_FE Dist_FE ymean N, ///
			label("Year-Month FE" "District FE" "Dep. Var. Mean" "Observations"))

	*Table A10
	estimates clear
	estimates use ${estpath}TWFE_all_log_tot_pmt
	eststo est1
	eststo est1,addscalars(Year_FE 1)
	eststo est1,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_all_tot_pmt
	eststo est2
	eststo est2,addscalars(Year_FE 1)
	eststo est2,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_all_log_rides
	eststo est3
	eststo est3,addscalars(Year_FE 1)
	eststo est3,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_all_ambulance_id
	eststo est4
	eststo est4,addscalars(Year_FE 1)
	eststo est4,addscalars(Dist_FE 1)

	label variable prior_auth "Prior Authorization"
	label variable post_civ "Civil Enforcement"
	label variable post_crim "Criminal Enforcement"

	esttab using ${outpath}Table_A10.tex, ///
		replace label se frag booktabs drop(_cons) ///
		star(+ 0.1 * 0.05 ** 0.01 *** 0.001) ///
		stats(Year_FE Dist_FE ymean N, ///
			label("Year-Month FE" "District FE" "Dep. Var. Mean" "Observations"))

	*Table A11
	estimates clear
	estimates use ${estpath}TWFE_prior_auth_ihs_pmt
	eststo est1
	eststo est1,addscalars(Year_FE 1)
	eststo est1,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_prior_auth_ihs_rides
	eststo est2
	eststo est2,addscalars(Year_FE 1)
	eststo est2,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_prior_auth_ihs_firms
	eststo est3
	eststo est3,addscalars(Year_FE 1)
	eststo est3,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_civil_ihs_pmt
	eststo est4
	eststo est4,addscalars(Year_FE 1)
	eststo est4,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_civil_ihs_rides
	eststo est5
	eststo est5,addscalars(Year_FE 1)
	eststo est5,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_criminal_ihs_pmt
	eststo est6
	eststo est6,addscalars(Year_FE 1)
	eststo est6,addscalars(Dist_FE 1)
	estimates use ${estpath}TWFE_criminal_ihs_rides
	eststo est7
	eststo est7,addscalars(Year_FE 1)
	eststo est7,addscalars(Dist_FE 1)

	label define post 100 "Treatment", replace
	label values post_together post

	label var ihs_pmt "\shortstack{Total Ride \\ Payments (IHS)}"
	label var ihs_rides "\shortstack{Total \\ Rides (IHS)}"
	label var ihs_firms "\shortstack{Active \\ Firms (IHS)}"

	esttab using ${outpath}Table_A11.tex, ///
		replace label se frag booktabs keep(*100*) ///
		star(+ 0.1 * 0.05 ** 0.01 *** 0.001) ///
		mgroups("Prior Auth." "Civil" "Criminal", pattern(1 0 0 1 0 1 0) ///
			prefix(\multicolumn{@span}{c}{) suffix(}) span ///
			erepeat(\cmidrule(lr){@span})) ///
		stats(Year_FE Dist_FE ymean N, ///
			label("Year-Month FE" "District FE" "Dep. Var. Mean" "Observations"))
				
	*Table A12
	estimates clear
	estimates use ${estpath}pois_prior_auth_tot_pmt
	eststo est1
	eststo est1,addscalars(Year_FE 1)
	eststo est1,addscalars(Dist_FE 1)
	estimates use ${estpath}pois_prior_auth_ambulance_id
	eststo est2
	eststo est2,addscalars(Year_FE 1)
	eststo est2,addscalars(Dist_FE 1)
	estimates use ${estpath}pois_prior_auth_active_firms
	eststo est3
	eststo est3,addscalars(Year_FE 1)
	eststo est3,addscalars(Dist_FE 1)
	estimates use ${estpath}pois_civil_tot_pmt
	eststo est4
	eststo est4,addscalars(Year_FE 1)
	eststo est4,addscalars(Dist_FE 1)
	estimates use ${estpath}pois_civil_ambulance_id
	eststo est5
	eststo est5,addscalars(Year_FE 1)
	eststo est5,addscalars(Dist_FE 1)
	estimates use ${estpath}pois_criminal_tot_pmt
	eststo est6
	eststo est6,addscalars(Year_FE 1)
	eststo est6,addscalars(Dist_FE 1)
	estimates use ${estpath}pois_criminal_ambulance_id
	eststo est7
	eststo est7,addscalars(Year_FE 1)
	eststo est7,addscalars(Dist_FE 1)

	esttab using ${outpath}Table_A12.tex, ///
		replace label se frag booktabs keep(*100*) ///
		star(+ 0.1 * 0.05 ** 0.01 *** 0.001) ///
		mgroups("Prior Auth." "Civil" "Criminal", pattern(1 0 0 1 0 1 0) ///
			prefix(\multicolumn{@span}{c}{) suffix(}) span ///
			erepeat(\cmidrule(lr){@span})) ///
		stats(Year_FE Dist_FE ymean N, ///
			label("Year-Month FE" "District FE" "Dep. Var. Mean" "Observations"))

	/*Intensive margin*/
	gen litigate=post_together_crim
	gen intense=crim_count
	estimates clear
	eststo: reghdfe log_tot_pmt ib99.litigate##ib1.intense i.post_civ i.prior_auth, a(dist_code month_date) vce(cluster dist_code)
	estadd local intensity "Discrete"
	estadd ysumm
	eststo est1,addscalars(Year_FE 1)
	eststo est1,addscalars(Dist_FE 1)
	eststo: reghdfe log_tot_pmt ib99.litigate##c.intense i.post_civ i.prior_auth, a(dist_code month_date) vce(cluster dist_code)
	estadd local intensity "Linear"
	estadd ysumm
	eststo est2,addscalars(Year_FE 1)
	eststo est2,addscalars(Dist_FE 1)
	replace intense=(crim_count>1)+50
	eststo: reghdfe log_tot_pmt ib99.litigate##ib50.intense i.post_civ i.prior_auth, a(dist_code month_date) vce(cluster dist_code)
	estadd local intensity "Multiple"
	estadd ysumm
	eststo est3,addscalars(Year_FE 1)
	eststo est3,addscalars(Dist_FE 1)

	replace litigate=post_together_civ
	replace intense=civ_count
	eststo: reghdfe log_tot_pmt ib99.litigate##ib1.intense i.post_crim i.prior_auth, a(dist_code month_date) vce(cluster dist_code)
	estadd local intensity "Discrete"
	estadd ysumm
	eststo est4,addscalars(Year_FE 1)
	eststo est4,addscalars(Dist_FE 1)
	eststo: reghdfe log_tot_pmt ib99.litigate##c.intense i.post_crim i.prior_auth, a(dist_code month_date) vce(cluster dist_code)
	estadd local intensity "Linear"
	estadd ysumm
	eststo est5,addscalars(Year_FE 1)
	eststo est5,addscalars(Dist_FE 1)
	replace intense=(civ_count>1)+50
	eststo: reghdfe log_tot_pmt ib99.litigate##ib50.intense i.post_crim i.prior_auth, a(dist_code month_date) vce(cluster dist_code)
	estadd local intensity "Multiple"
	estadd ysumm
	eststo est6,addscalars(Year_FE 1)
	eststo est6,addscalars(Dist_FE 1)

	label define post 100 "Enforcement", replace
	label values litigate post
	label var intense "Intensity"
	label define post_inter 2 "2 Cases" 3 "3 Cases" 4 "4 Cases" 5 "5 Cases" 6 "6 Cases" 7 "7 Cases" 8 "8 Cases" 9 "9 Cases" 10 "10 Cases" 51 "Intensity", replace
	label values intense post_inter

	*Table A20
	esttab using ${outpath}Table_A20.tex, ///
		replace label se frag booktabs keep(100.litigate*) drop(*#0.in* *#1.in* *#50.in*) ///
		mgroups("Criminal" "Civil", pattern(1 0 0 1 0 0) ///
			prefix(\multicolumn{@span}{c}{) suffix(}) span ///
			erepeat(\cmidrule(lr){@span})) ///
		star(+ 0.1 * 0.05 ** 0.01 *** 0.001) ///
		stats(intensity Year_FE Dist_FE ymean N, ///
			label("Intensity Measure" "Year-Month FE" "District FE" "Dep. Var. Mean" "Observations"))

	*Testing equality of effects across treatments
	label var log_tot_pmt "Total Payments in District (Log)"
	label var log_rides "Total Rides in District (Log)"
	label var log_active_firms "Active Firms in District (Log)"

	foreach var in log_tot_pmt log_rides log_active_firms {
		if "var"!="log_active_firms" {
			estimates clear
			eststo: reg `var' ib99.post_together_civ i.post_crim i.prior_auth i.dist_code ib612.month_date
			eststo: reg `var' ib99.post_together_crim i.prior_auth i.post_civ i.dist_code ib612.month_date
			eststo: reg `var' ib99.post_together_PA i.post_crim i.post_civ i.dist_code ib612.month_date if month_date>=612
		}
		
		matrix test_this = [0,0,0]
		
		suest est1 est2 est3, vce(cluster dist_code)
		test [est1_mean]100.post_together_civ=[est2_mean]100.post_together_crim
		matrix test_this[1,1]=`r(p)'
		test [est1_mean]100.post_together_civ=[est3_mean]100.post_together_PA
		matrix test_this[1,2]=`r(p)'
		test [est3_mean]100.post_together_PA=[est2_mean]100.post_together_crim
		matrix test_this[1,3]=`r(p)'
				
		matrix rownames test_this = "`: variable label `var''"
		if "`var'"=="log_tot_pmt" {
			matrix test = test_this
			matrix colnames test = "Civil vs Criminal" "Civil vs Prior Auth" "Criminal vs Prior Auth"
		}
		else if "`var'" == "log_active_firms" {
			reg `var' ib99.post_together_PA_firm i.post_crim i.post_civ i.dist_code ib612.month_date if month_date>=612, vce(cluster dist_code)
			
			matrix test_this[1,1]=0.475
			local z=(_b[100.post_together_PA_firm]-0.0122476)/sqrt(_se[100.post_together_PA`suff']^2+0.0289675^2)
			matrix test_this[1,2]=2*normal(-abs(`z'))
			local z=(_b[100.post_together_PA_firm]-(-0.0442496))/sqrt(_se[100.post_together_PA`suff']^2+0.0731056^2)
			matrix test_this[1,3]=2*normal(-abs(`z'))

			matrix test=test\test_this
		}
		else {
			matrix test=test\test_this
		}
	}
	
	esttab m(test, fmt(%9.3f)) using ${outpath}Table_A32.tex, booktabs nomti frag replace // Table A32
}


*Three treats
qui gen months_since=0
qui gen months_since_plot=_n

foreach var in log_tot_pmt log_rides log_active_firms {
	local suff=""
	if "`var'"=="active_firms" | "`var'"=="log_active_firms" | "`var'"=="ihs_firms" {
		local suff="_firm"
	}
	qui {
		estimates clear
		replace months_since=months_since_civ100`suff'
		reghdfe `var' ib99.months_since i.prior_auth i.post_crim, a(dist_code month_date) vce(cluster dist_code)
		gen coef_civ_`var'=e(b)[1,months_since_plot+1]
		gen coef_civ_`var'll=r(table)[5,months_since_plot+1]
		gen coef_civ_`var'ul=r(table)[6,months_since_plot+1]
		replace months_since=months_since_crim100`suff'
		reghdfe `var' ib99.months_since i.prior_auth i.post_civ, a(dist_code month_date) vce(cluster dist_code)
		gen coef_crim_`var'=e(b)[1,months_since_plot+1]
		gen coef_crim_`var'll=r(table)[5,months_since_plot+1]
		gen coef_crim_`var'ul=r(table)[6,months_since_plot+1]
		replace months_since=months_since_PA100`suff'
		reghdfe `var' ib99.months_since i.post_crim i.post_civ if month_date>=612, a(dist_code month_date) vce(cluster dist_code)
		gen coef_PA_`var'=e(b)[1,months_since_plot+1]
		gen coef_PA_`var'll=r(table)[5,months_since_plot+1]
		gen coef_PA_`var'ul=r(table)[6,months_since_plot+1]
		
		if "`var'"=="log_active_firms" {
			replace coef_crim_log_active_firms=0.072913 if months_since_plot==1
			replace coef_crim_log_active_firms=0.1271983 if months_since_plot==2
			replace coef_crim_log_active_firms=0.0874526 if months_since_plot==3
			replace coef_crim_log_active_firms=0.0930049 if months_since_plot==4
			replace coef_crim_log_active_firms=0.1207704 if months_since_plot==5
			replace coef_crim_log_active_firms=0.0967808 if months_since_plot==6
			replace coef_crim_log_active_firms=0.1270669 if months_since_plot==7
			replace coef_crim_log_active_firms=0.0642974 if months_since_plot==8
			replace coef_crim_log_active_firms=0.0451854 if months_since_plot==9
			replace coef_crim_log_active_firms=0.0117662 if months_since_plot==10
			replace coef_crim_log_active_firms=0.0367119 if months_since_plot==11
			replace coef_crim_log_active_firms=0.0286275 if months_since_plot==12
			replace coef_crim_log_active_firms=0.0494107 if months_since_plot==13
			replace coef_crim_log_active_firms=0.0434709 if months_since_plot==14
			replace coef_crim_log_active_firms=0.0020917 if months_since_plot==15
			replace coef_crim_log_active_firms=0.0502252 if months_since_plot==16
			replace coef_crim_log_active_firms=0.110367 if months_since_plot==17
			replace coef_crim_log_active_firms=0.0458133 if months_since_plot==18
			replace coef_crim_log_active_firms=0.029368 if months_since_plot==19
			replace coef_crim_log_active_firms=0.0106828 if months_since_plot==20
			replace coef_crim_log_active_firms=0.0454713 if months_since_plot==21
			replace coef_crim_log_active_firms=0.0471174 if months_since_plot==22
			replace coef_crim_log_active_firms=0.0091867 if months_since_plot==23
			replace coef_crim_log_active_firms=0.0 if months_since_plot==24
			replace coef_crim_log_active_firms=0.0364097 if months_since_plot==25
			replace coef_crim_log_active_firms=0.0516673 if months_since_plot==26
			replace coef_crim_log_active_firms=0.1021463 if months_since_plot==27
			replace coef_crim_log_active_firms=-0.0715971 if months_since_plot==28
			replace coef_crim_log_active_firms=-0.0036712 if months_since_plot==29
			replace coef_crim_log_active_firms=-0.0984408 if months_since_plot==30
			replace coef_crim_log_active_firms=-0.0322913 if months_since_plot==31
			replace coef_crim_log_active_firms=-0.0207831 if months_since_plot==32
			replace coef_crim_log_active_firms=-0.0500044 if months_since_plot==33
			replace coef_crim_log_active_firms=-0.0411717 if months_since_plot==34
			replace coef_crim_log_active_firms=-0.0250933 if months_since_plot==35
			replace coef_crim_log_active_firms=-0.015885 if months_since_plot==36
			replace coef_crim_log_active_firms=-0.0667158 if months_since_plot==37
			replace coef_crim_log_active_firms=-0.0477346 if months_since_plot==38
			replace coef_crim_log_active_firms=-0.0785844 if months_since_plot==39
			replace coef_crim_log_active_firms=-0.0526243 if months_since_plot==40
			replace coef_crim_log_active_firms=-0.0965178 if months_since_plot==41
			replace coef_crim_log_active_firms=-0.0891376 if months_since_plot==42
			replace coef_crim_log_active_firms=-0.0865389 if months_since_plot==43
			replace coef_crim_log_active_firms=-0.0622299 if months_since_plot==44
			replace coef_crim_log_active_firms=-0.1038087 if months_since_plot==45
			replace coef_crim_log_active_firms=-0.0849209 if months_since_plot==46
			replace coef_crim_log_active_firms=-0.0561396 if months_since_plot==47
			replace coef_crim_log_active_firms=-0.0671494 if months_since_plot==48

			replace coef_civ_log_active_firms=0.0774507 if months_since_plot==1
			replace coef_civ_log_active_firms=-0.0106794 if months_since_plot==2
			replace coef_civ_log_active_firms=-0.0021771 if months_since_plot==3
			replace coef_civ_log_active_firms=0.0006894 if months_since_plot==4
			replace coef_civ_log_active_firms=0.0594871 if months_since_plot==5
			replace coef_civ_log_active_firms=0.0687512 if months_since_plot==6
			replace coef_civ_log_active_firms=0.0649855 if months_since_plot==7
			replace coef_civ_log_active_firms=-0.0280148 if months_since_plot==8
			replace coef_civ_log_active_firms=0.0100127 if months_since_plot==9
			replace coef_civ_log_active_firms=0.0514865 if months_since_plot==10
			replace coef_civ_log_active_firms=0.0461303 if months_since_plot==11
			replace coef_civ_log_active_firms=0.0231952 if months_since_plot==12
			replace coef_civ_log_active_firms=0.0661827 if months_since_plot==13
			replace coef_civ_log_active_firms=0.0963315 if months_since_plot==14
			replace coef_civ_log_active_firms=0.0314718 if months_since_plot==15
			replace coef_civ_log_active_firms=0.0775342 if months_since_plot==16
			replace coef_civ_log_active_firms=0.0688942 if months_since_plot==17
			replace coef_civ_log_active_firms=0.097636 if months_since_plot==18
			replace coef_civ_log_active_firms=0.1041944 if months_since_plot==19
			replace coef_civ_log_active_firms=0.0872717 if months_since_plot==20
			replace coef_civ_log_active_firms=0.0537977 if months_since_plot==21
			replace coef_civ_log_active_firms=0.0024343 if months_since_plot==22
			replace coef_civ_log_active_firms=-0.0195693 if months_since_plot==23
			replace coef_civ_log_active_firms=0.0 if months_since_plot==24
			replace coef_civ_log_active_firms=0.0157049 if months_since_plot==25
			replace coef_civ_log_active_firms=-0.0085397 if months_since_plot==26
			replace coef_civ_log_active_firms=0.0263144 if months_since_plot==27
			replace coef_civ_log_active_firms=0.018989 if months_since_plot==28
			replace coef_civ_log_active_firms=0.0298541 if months_since_plot==29
			replace coef_civ_log_active_firms=0.0761345 if months_since_plot==30
			replace coef_civ_log_active_firms=0.0492703 if months_since_plot==31
			replace coef_civ_log_active_firms=0.0146894 if months_since_plot==32
			replace coef_civ_log_active_firms=0.0532449 if months_since_plot==33
			replace coef_civ_log_active_firms=-0.0274861 if months_since_plot==34
			replace coef_civ_log_active_firms=-0.0402403 if months_since_plot==35
			replace coef_civ_log_active_firms=-0.0130546 if months_since_plot==36
			replace coef_civ_log_active_firms=-0.0783442 if months_since_plot==37
			replace coef_civ_log_active_firms=-0.0194587 if months_since_plot==38
			replace coef_civ_log_active_firms=-0.0313874 if months_since_plot==39
			replace coef_civ_log_active_firms=-0.0415347 if months_since_plot==40
			replace coef_civ_log_active_firms=-0.0027668 if months_since_plot==41
			replace coef_civ_log_active_firms=0.0269179 if months_since_plot==42
			replace coef_civ_log_active_firms=0.0484709 if months_since_plot==43
			replace coef_civ_log_active_firms=-0.0014068 if months_since_plot==44
			replace coef_civ_log_active_firms=0.053352 if months_since_plot==45
			replace coef_civ_log_active_firms=0.0774887 if months_since_plot==46
			replace coef_civ_log_active_firms=0.053352 if months_since_plot==47
			replace coef_civ_log_active_firms=0.0155726 if months_since_plot==48
		}
	}
	if "`var'"=="log_tot_pmt" {
		twoway (line coef_civ_log_tot_pmt months_since_plot) ///
			(line coef_crim_log_tot_pmt months_since_plot, lpatt(shortdash)) ///
			(line coef_PA_log_tot_pmt months_since_plot, lpatt(longdash)) ///
			(pcarrowi -0.775 32.5 -0.85 31.5, color(black)) ///
			(pcarrowi -0.35 34.5 -0.275 35, color(black)) ///
			(pcarrowi 0.11 35.2 0.06 34.5, color(black)) if months_since_plot<49, ///
			text(-0.75 32.5 "Prior Authorization", placement(e)) ///
			text(-0.4 26 "Criminal Enforcement", placement(e)) ///
			text(0.17 33 "Civil Enforcement", placement(e)) ///
			xti(Months Since Enforcement) ///
			xlab(1 "-24" 7 "-18" 13 "-12" 19 "-6" 25 "0" ///
				31 "6" 37 "12" 43 "18" 49 "24") ///
			xline(25, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) ///
			yti("Total Payments in District (Logs)") ///
			ylab(, nogrid angle(0)) leg(off) ///
			graphregion(color(white)) bgcolor(white) ///
			aspect(0.525) ysize(9) xsize(16)
		qui graph export ${outpath}Figure_5.pdf, as(pdf) replace // Figure 5
	}
	if "`var'"!="log_tot_pmt" {
		twoway (line coef_civ_`var' months_since_plot) ///
			(line coef_crim_`var' months_since_plot, lpatt(shortdash)) ///
			(line coef_PA_`var' months_since_plot, lpatt(longdash)) if months_since_plot<49, ///
			xti(Months Since Enforcement) ///
			xlab(1 "-24" 7 "-18" 13 "-12" 19 "-6" 25 "0" ///
				31 "6" 37 "12" 43 "18" 49 "24") ///
			xline(25, lcolor(gs8) lpattern(dash)) yline(0, lcolor(gs8)) ///
			yti("`:variable label `var''") ///
			ylab(, nogrid angle(0)) ///
			leg(order(1 "Civil Enforcement" 2 "Criminal Enforcement" 3 "Prior Authorization")) ///
			graphregion(color(white)) bgcolor(white) ///
			aspect(0.525) ysize(9) xsize(16)
		if "`var'"=="log_rides" {
			qui graph export ${outpath}Figure_A18a.pdf, as(pdf) replace // Figure A18a
		}
		if "`var'"=="log_active_firms" {
			qui graph export ${outpath}Figure_A18b.pdf, as(pdf) replace // Figure A18b
		}
	}
}


log close